#include "myobject.h"
#include <QObject>
#include <QPropertyAnimation>
#include <QPoint>
#include <QPixmap>
#include <QPainter>
MyObject::MyObject(QPoint startpos,QPoint targetPos,QString fileName):QObject(0),pixmap(fileName){
    this->currentPos=startPos;
    this->startPos=startPos;
    this->targetPos=targetPos;
}
void MyObject::draw(QPainter*painter){
    painter->drawPixmap(currentPos,pixmap);
}
void MyObject::move(){
    QPropertyAnimation*animation=new QPropertyAnimation(this,"currentPos");
    animation->setDuration(2000);
    animation->setStartValue(startPos);
    animation->setEndValue(targetPos);
    animation->start();
}
QPoint MyObject::getCurrentPos(){
    return this->currentPos;
}
void MyObject::setCurrentPos(QPoint pos){
    this->currentPos=pos;
}
